package dk.modified.reshary;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.Button;

public class FragmentPageThree extends Fragment {
	private Button cmd_next;
	private Button cmd_previous;

	public FragmentPageThree() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_page_three,
				container, false);
		setViews(rootView);
		setOnClickListeners();
		return rootView;
	}

	private void setViews(View v) {
		cmd_next = (Button) v.findViewById(R.id.cmd_next);
		cmd_previous = (Button) v.findViewById(R.id.cmd_prev);
	}

	private void setOnClickListeners() {
		cmd_next.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SharedPreferences sharedpreferences = getActivity()
						.getApplicationContext().getSharedPreferences(
								"dk.modified.reshary", Context.MODE_PRIVATE);
				Editor editor = sharedpreferences.edit();
				editor.putBoolean("showintro", false);
				editor.commit();
				Intent j = new Intent(getActivity().getApplicationContext(),
						SplashScreen.class);
				j.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
						| Intent.FLAG_ACTIVITY_CLEAR_TASK);
				startActivity(j);
			}
		});

		cmd_previous.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				getActivity().getFragmentManager().beginTransaction()
						.replace(R.id.container, new FragmentPageTwo())
						.commit();
			}
		});
	}
}
